﻿using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;

using System.Collections.Generic;
using OpenSda.Agilcont.Common.Business.Contracts;
using OpenSda.Agilcont.Common.Data.Entities;
using OpenSda.Agilcont.Common.Data.Contracts;
using OpenSda.Agilcont.Common.Business.Exceptions;

namespace OpenSda.Agilcont.Common.Business.SfContexts.NmTest
{
    [TestFixture]
    public class TipoCambioBusinessTest : AbstractBaseDataTests
    {
        private ITipoCambioBusiness target;
        public ITipoCambioBusiness tipoCambioBusiness { set { target = value; } }
        
        public IEmpresaData empresaData;
        public IEmpresaData EmpresaData{ set {empresaData = value;}}

        [Test]
        [ExpectedException(typeof(TipoCambioCannotBeNullException))]
        public void SaveWhenEmpresaIsNullTest()
        {
            target.Save(null);
        }

        [Test]
        public void SaveTest()
        {
            TipoCambio tipoCambio = this.Save();
            Assert.IsNotNull(tipoCambio.Identity);
        }
        private TipoCambio Save()
        {
          Empresa e = empresaData.GetAll()[0];
            return target.Save(new TipoCambio()
            {
             // Fecha = new DateTime(2012, 12, 12, 34),
                Compra = 23.4,
                Venta = 25.0,
                 EmpresaRef = e
            });
        }

        [Test]
        public void TipoCambiotByIdTests()
        {
            TipoCambio e = target.GetById("");
            Assert.IsNotNull(e);
        }

        private TipoCambio GetBayId()
        {
            return target.GetById(new object());

        }

        [Test]
        public void TipoCambioetLisByfiltertTests()
        {
            var e = target.GetListByFilter("");

            Assert.IsNotNull(e);
        }

        [Test]
        public void TipoCambioeleteTests()
        {
            TipoCambio e = new TipoCambio();
            e.Compra = 1;
            target.Delete(e);
        }
    }
}
